<?php

namespace App\Models;

use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Yansongda\Pay\Gateways\Wechat;

class User extends Authenticatable implements JWTSubject
{
    use Notifiable;

    protected $table = 'users';
    protected $guarded = [];


    public function getJWTIdentifier()
    {
        return $this->getKey();
    }

    public function getJWTCustomClaims()
    {
        return [];
    }

    /**
     * Notes: 关联物业信息
     * User: lstink
     * Date: 2021/3/4
     * Time: 2:26 下午
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function estate()
    {
        return $this->hasOne(Community::class, 'community_id', 'community_id');
    }

    /**
     * 2021/3/19--9:52
     * @effect:关联业主表
     * @author:苏冬冬
     * @QQ:1299273928
     * @method:one_owner
     */
    public function one_owner()
    {
        return $this->hasOne(Users::class, "unionid", "unionid");
    }

    /**
     * 2021/3/19--9:52
     * @effect:关联业主表
     * @author:苏冬冬
     * @QQ:1299273928
     * @method:one_owner
     */
    public function one_fans()
    {
        return $this->hasOne(WechatFans::class, 'unionid', 'unionid')->where(["type"=>1]);
    }
}
